from mysqlx import init_db, db
from config import DB_CONF


def full_test():
    db.sql('INSERT INTO person(name,age) VALUES(?,?)').execute('lisi', 26)

    print(db.sql('select * from person').select())
    print(db.sql('select * from person').select_one())

    print(db.sql('select id, name, age from person').query())
    print(db.sql('select id, name, age from person where name = ?').query_one('lisi'))
    print(db.sql('select id, name, age from person where name = :name').query_one(name='lisi'))

    print(db.sql('select count(1) from person').get())

    for u in db.sql('select * from person').select_page(1, 4):
        print(u)

    for u in db.sql('select * from person').page(1, 4).select():
        print(u)


if __name__ == '__main__':
    init_db(**DB_CONF)
    full_test()
